package org.wanho.rent.service.proxy;

import org.wanho.jdbc.transaction.TransactionManager;
import org.wanho.rent.entity.SysUser;
import org.wanho.rent.exception.LoginException;
import org.wanho.rent.exception.ServiceException;
import org.wanho.rent.factory.ObjectFactory;
import org.wanho.rent.service.SysuserService;

public class SysuserServiceProxy implements SysuserService{
	
	private TransactionManager tx = (TransactionManager) ObjectFactory.getObject("tx");
	private SysuserService sysuserService = (SysuserService) ObjectFactory.getObject("sysuserService");

	@Override
	public SysUser login(String loginname, String loginpassword)
			throws LoginException {
		try {
			tx.beginTransaction();
			SysUser user = sysuserService.login(loginname, loginpassword);
			tx.commit();
			return user;
		} catch (Exception e) {
			tx.rollback();
			throw new ServiceException(e.getMessage());
		}
	}

}
